class Student:
    def __init__(self, name, age):
        self.__name = name
        self.__age = age

    def show(self):
        print(f'我叫:{self.__name},我今年:{self.__age}岁了')


class Student:
    def __init__(self, name):
        self.__name = name

    # 使用 @property
    @property
    def age(self):  # 设置只读属性
        return self.__age

    # 设置赋值操作
    @age.setter
    def age(self, value):
        if value < 0 or value > 130:
            print('年龄不在正确的区间范围,设置年龄的范围应该是0-130之间')
            self.__age = 18  # 设置默认值
        else:
            self.__age = value

    def show(self):
        print(f'我叫:{self.__name},我今年:{self.__age}岁了')


if __name__ == '__main__':
    stu = Student('duiduo')
    stu.age = -20
    print(stu.age)
    stu.show()
    stu.age = 20
    stu.show()